/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package prjtgl.controler.administrateur;

import prjtgl.controler.membre.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.*;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.*;
import prjtgl.bdd.comptes.profil_utilisateur.HDomaineExpertise;
import prjtgl.metier.Application;
import prjtgl.metier.comptes.Membre;
import prjtgl.metier.comptes.profil_utilisateur.DomaineExpertise;
import prjtgl.metier.comptes.profil_utilisateur.Profil;
/**
 *
 * @author Adrien
 */
public class Administration  extends SelectorComposer {
   
    @Wire
    Textbox newdomaine;
    
    private DomaineExpertise selected;
    private List<DomaineExpertise1> domaineExpertise = new ArrayList<DomaineExpertise1>();
    
    @Init
    public void init()
    {
        Application ap = Application.getInstance();
       
         for(DomaineExpertise d : ap.listerDomainesExpertise()){
            
             domaineExpertise.add(new DomaineExpertise1(d));
         }
        
         
         /*DomaineExpertise domaineExpertiseNull = new DomaineExpertise();
         domaineExpertiseNull.setIntitule("Non renseigné");
         domaineExpertise.add(0, domaineExpertiseNull);*/

    }
    
    
    public class DomaineExpertise1{
        
        DomaineExpertise1(DomaineExpertise d){
            monDom=d;
        }
        
        private DomaineExpertise monDom=null;
        
        
        private String newVal="";
        
        public String getNewVal(){
            return newVal;
        }
        
        public DomaineExpertise getMonDom(){
            return monDom;
        }
        
        public void setNewVal(String content){
            newVal=content;
        }
    }
       
     public List<DomaineExpertise1> getDomaineExpertiseList() { return domaineExpertise;}     
     public void setSelectedDomaineExpertise(DomaineExpertise selected) { this.selected = selected; }     
     public DomaineExpertise getSelectedDomaineExpertise() { return selected; }
     
     
      @Command
     public void supprimerDomaine(@BindingParam("content") String content){
         Application.getInstance().supprimerDomaineExpertise(content);
          
       
      }
      
      
      @Command
     public void modifierDomaine(@BindingParam("content") String content,@BindingParam("nouveau") DomaineExpertise1 nouveau){
          System.out.println(content+" ==>  "+nouveau.getNewVal());
          
          Application.getInstance().editerDomaineExpertise(content, nouveau.getNewVal());
         
          
       
      }
     
     
     @Command
     public void ajoutDomaine(@BindingParam("content") String content){
         String str =content;
         if(str.equals("")){ return;}
         DomaineExpertise d=Application.getInstance().ajouterDomaineExpertise(str);
         
        
     }
}

